package top.xxyu.shiro;

import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.authc.credential.SimpleCredentialsMatcher;

public class CredentialsMatcher extends SimpleCredentialsMatcher{
	
	@Override
	public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
		UsernamePasswordToken userToken = (UsernamePasswordToken) token;
		//获取用户输入的密码：(可以采用加盐(salt)的方式去检验)
		String password = new String(userToken.getPassword());
		//获得数据库中的密码
		String dbPassword = (String)info.getCredentials();
		
		return this.equals(password, dbPassword);
		
	}

}
